<template>
  <div class="madp-dialog" v-show="visible">
    <div class="dialog-bg"></div>
    <div class="container">
      <div class="com-dialog-container" :style="{ width: width }">
        <div class="header">
          <span class="title">{{ title }}</span>
          <i class="el-icon-close cursor-pointer" @click="closeDialog"></i>
        </div>
        <slot></slot>
        <div class="madp-btns">
          <div class="btn btn1 cursor-pointer" @click="cancel">取消</div>
          <div class="btn btn2 cursor-pointer" v-debounce="confirm">确定</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'DialogComponent',
  components: {},
  data() {
    return {}
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    width: {
      type: String,
      default: '100%'
    },
    title: {
      type: String,
      default: ''
    }
  },
  created() {},
  mounted() {},
  methods: {
    closeDialog() {
      this.$emit('update:visible', false)
    },
    cancel() {
      this.$emit('update:visible', false)
    },
    confirm() {
      this.$emit('confirm')
    }
  }
}
</script>
<style scoped lang='scss'>
.madp-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  .dialog-bg {
    width: 100%;
    height: 100%;
    opacity: 0.5;
    background: #000;
  }
  .container {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    .com-dialog-container {
      position: relative;
      padding: 0 20px;
      padding-top: 10px;
      padding-bottom: 20px;
      border-radius: 5px;
      background: #fff;
      .header {
        width: 100%;
        margin-bottom: 10px;
        .title {
          font-size: 15px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #2c2c2c;
        }
        .el-icon-close {
          font-size: 16px;
          position: absolute;
          top: 5px;
          right: 6px;
        }
      }
      .madp-btns {
        display: flex;
        justify-content: space-evenly;
        .btn {
          width: 75px;
          height: 35px;
          border-radius: 15px;
          text-align: center;
          line-height: 35px;
          font-size: 14px;
        }
        .btn1 {
          background-color: #fff;
          border: 1px solid #dbd3d3;
          color: #2c2c2c;
        }
        .btn2 {
          background: #ed5555;
          color: #fff;
        }
      }
    }
  }
}
</style>